<?xml version="1.0"?>
<ScatterFile xmlns="http://schemas.microsoft.com/netmf/ScatterfileSchema.xsd">

    <Set Name="Valid" Value="false"/>

    <Set Name="TTB_BaseAddress"             Value="0x20000000"/>
    <Set Name="TTB_Size"                    Value="0x00004000"/>
    <Set Name="BL_BaseAddress"              Value="0x18000000"/>
    <Set Name="BL_Size"                     Value="0x00004000"/>
    <Set Name="Code_BaseAddress"            Value="0x18004000"/>
    <Set Name="Code_Size"                   Value="0x001ec000"/>
    <Set Name="ER_RAM_RO_BaseAddress"       Value="0x20100000"/>
    <Set Name="ER_RAM_RO_Size"              Value="0x001a0000"/>
    <Set Name="Heap_Begin"                  Value="0x20300000"/>
    <Set Name="Heap_End"                    Value="0x209dfffc"/>
    <Set Name="CustomHeap_Begin"            Value="0x202a0000"/>
    <Set Name="CustomHeap_End"              Value="0x202efffc"/>
    <Set Name="Stack_Bottom"                Value="0x202f0000"/>
    <Set Name="Stack_Top"                   Value="0x202ffffc"/>
<!--
    <Set Name="Rvectors_Begin"              Value="0x1802f000"/>
    <Set Name="Fvectors_Begin"              Value="0x1802ff80"/>
-->

    <If Name="TARGETLOCATION" Value="FLASH">
        <Set Name="Valid"                   Value="true"/>
        <Set Name="Deploy_BaseAddress"      Value="0x18200000"/>
        <Set Name="Config_BaseAddress"      Value="0x181f0000"/>    
        <Set Name="Config_Size"             Value="0x00001000"/>
        <Set Name="Valid"                   Value="true"/>
    </If>

    <If Name="TARGETLOCATION" Value="RAM">
        <Set Name="Valid"                   Value="true"/>
        <Set Name="Deploy_BaseAddress"      Value="0x20100000"/>
        <Set Name="Config_BaseAddress"      Value="0x201d0000"/>    
        <Set Name="Config_Size"             Value="0x00002000"/>
        <Set Name="Valid"                   Value="true"/>
    </If>

    <If Name="Valid" Value="false">
        <Error Message="Configuration not recognized"/>
    </If>

    <NamedGroup Name="MEMORY">
        <LoadRegion Name="ER_TTB" Base="%TTB_BaseAddress%" Size="%TTB_Size%"/>
        <LoadRegion Name="LR_BOOT_LOADER" Base="%BL_BaseAddress%" Size="%BL_Size%"/>
        <LoadRegion Name="LR_%TARGETLOCATION%" Base="%Code_BaseAddress%" Size="%Code_Size%"/>
        <IfDefined Name="Config_BaseAddress">
            <LoadRegion Name="LR_CONFIG" Base="%Config_BaseAddress%" Size="%Config_Size%"/>
        </IfDefined>
        <IfDefined Name="Data_BaseAddress">
            <LoadRegion Name="LR_DAT" Base="%Data_BaseAddress%" Size="%Data_Size%"/>
        </IfDefined>
        <LoadRegion Name="HEAP" Base="%Heap_Begin%" Size="%Heap_End - Heap_Begin% + 1"/>
        <LoadRegion Name="STACK" Base="%Stack_Bottom%" Size="%Stack_Top - Stack_Bottom% + 1"/>
        <LoadRegion Name="RELOC_RAM" Base="%ER_RAM_RO_BaseAddress%" Size="%ER_RAM_RO_Size%"/>
<!--
        <LoadRegion Name="RVECTORS" Base="%Rvectors_Begin%" Size="0x400"/>
        <LoadRegion Name="FVECTORS" Base="%Fvectors_Begin%" Size="0x80"/>
-->
    </NamedGroup>

    <EntryPoint Name="EntryPoint"/>

    <NamedGroup Name="SECTIONS">
        <ExecRegion Name="ER_BOOT_LOADER" Options="&gt;LR_BOOT_LOADER">
            <FileMapping Name="KEEP(*(.boot_loader))" />
        </ExecRegion>
        <ExecRegion Name="ER_%TARGETLOCATION%" Options="&gt;LR_%TARGETLOCATION%">
            <FileMapping Name="*" Options="(i.EntryPoint)" />
            <FileMapping Name="*" Options="(SectionForBootstrapOperations)" />
            <!-- libc thinks that it needs these routines, but they are never called -->
            <Include File="%SPOCLIENT%\Solutions\%PLATFORM%\scatterfile_gcc_missing_symbols.xml"/>
        </ExecRegion>

        <ExecRegion Name="ER_RAM_RO" Align="0x10" Options="&gt;RELOC_RAM AT&gt;LR_%TARGETLOCATION%">
            <FileMapping Name="*" Options="(.text*)" />
            <FileMapping Name="*" Options="(i.*)" />
            <If Name="TARGETLOCATION" In="RAM">     
                <FileMapping Name="*" Options="(SectionForFlashOperations)" />
            </If>
            <FileMapping Name="*" Options="(.rodata*)" />
            <FileMapping Name="*" Options="(rodata)" />
            <FileMapping Name="*" Options="(.constdata*)" />
            <FileMapping Name="*" Options="(.conststring*)" />
            <IfNotDefined Name="Data_BaseAddress">
                <FileMapping Name="*" Options="(tinyclr_metadata)" />
            </IfNotDefined>
            <IfNotDefined Name="Config_BaseAddress">
                <FileMapping Name="*" Options="(SectionForConfig)" />
            </IfNotDefined>
            <FileMapping Name="*" Options="(SectionForRvectors)" />
            <FileMapping Name="*" Options="(SectionForFlashOperations)" />
            <FileMapping Name="*" Options="(.text.RZA1_BS_Driver*)"/>
        </ExecRegion>
    
        <ExecRegion Name="ER_RAM_RW" Align="0x10" Options="&gt;RELOC_RAM AT&gt;LR_%TARGETLOCATION%">
            <FileMapping Name="*" Options="(rwdata)" />
            <FileMapping Name="*" Options="(.data*)" />
        </ExecRegion>

        <ExecRegion Name=".bss" Align="0x10" Options="&gt;RELOC_RAM">
            <FileMapping Name="*" Options="(.zidata*)" />
            <FileMapping Name="*" Options="(.bss*)" />
            <FileMapping Name="PROVIDE(__exidx_start = .);" />
            <FileMapping Name="PROVIDE(__exidx_end = .);" />
         </ExecRegion>
      
        <ExecRegion Name="/DISCARD/">
            <FileMapping Name="*" Options="(.ARM.exidx*)" />
            <FileMapping Name="*" Options="(.ARM.extab*)" />
        </ExecRegion>

        <ExecRegion Name="ER_TTB" Align="0x10" Options="&gt;ER_TTB">
        </ExecRegion>
<!--
        <ExecRegion Name="RVECTORS_TBL" Options="&gt;RVECTORS AT&gt;RVECTORS">
            <FileMapping Name="KEEP(*(SectionForRvectors))" />
        </ExecRegion>

        <ExecRegion Name="FVECTORS_TBL" Options="&gt;FVECTORS AT&gt;FVECTORS">
            <FileMapping Name="KEEP(*(SectionForFvectors))" />
        </ExecRegion>
-->
        <ExecRegion Name="ER_HEAP_BEGIN" Base="%Heap_Begin%">
            <FileMapping Name="*" Options="(SectionForHeapBegin)" />
        </ExecRegion>

        <ExecRegion Name="ER_HEAP_END" Base="%Heap_End%">
            <FileMapping Name="*" Options="(SectionForHeapEnd)" />
        </ExecRegion>

        <ExecRegion Name="ER_CUSTOM_HEAP_BEGIN" Base="%CustomHeap_Begin%">
        <FileMapping Name="*" Options="(SectionForCustomHeapBegin)" />
        </ExecRegion>

        <ExecRegion Name="ER_CUSTOM_HEAP_END" Base="%CustomHeap_End%">
        <FileMapping Name="*" Options="(SectionForCustomHeapEnd)" />
        </ExecRegion>

        <ExecRegion Name="ER_STACK_BOTTOM" Base="%Stack_Bottom%">
            <FileMapping Name="*" Options="(SectionForStackBottom)" />
        </ExecRegion>
    
         <ExecRegion Name="ER_STACK_TOP" Base="%Stack_Top%">
             <FileMapping Name="*" Options="(SectionForStackTop)" />
        </ExecRegion>

        <IfDefined Name="Config_BaseAddress">         
            <ExecRegion Name="ER_CONFIG" Options="&gt;LR_CONFIG">
                <FileMapping Name="*" Options="(SectionForConfig)" />
                <FileMapping Name="KEEP(*(SectionForConfig1))" />
            </ExecRegion>
        </IfDefined>    
      
        <IfDefined Name="Data_BaseAddress">      
            <ExecRegion Name="ER_DAT" Options="&gt;LR_DAT">
                <FileMapping Name="*" Options="(tinyclr_metadata)" />
            </ExecRegion>
         </IfDefined>
    </NamedGroup>

     <!-- The following variables are used to simulate the ones autogenerated by RVDS -->
    <GlobalVariable Name="Load$$ER_%TARGETLOCATION%$$Base"         Value="ADDR(ER_%TARGETLOCATION%)"/>
    <GlobalVariable Name="Image$$ER_%TARGETLOCATION%$$Length"      Value="SIZEOF(ER_%TARGETLOCATION%)"/>
    <GlobalVariable Name="Image$$ER_RAM_RO$$Base"                  Value="ADDR(ER_RAM_RO)"/>
    <GlobalVariable Name="Image$$ER_RAM_RO$$Length"                Value="SIZEOF(ER_RAM_RO)"/>
    <GlobalVariable Name="Load$$ER_RAM_RO$$Base"                   Value="LOADADDR(ER_RAM_RO)"/>
    <GlobalVariable Name="Image$$ER_RAM_RW$$Base"                  Value="ADDR(ER_RAM_RW)"/>
    <GlobalVariable Name="Image$$ER_RAM_RW$$Length"                Value="SIZEOF(ER_RAM_RW)"/>
    <GlobalVariable Name="Load$$ER_RAM_RW$$Base"                   Value="LOADADDR(ER_RAM_RW)"/>
    <GlobalVariable Name="Image$$ER_RAM_RW$$ZI$$Base"              Value="ADDR(.bss)"/>
    <GlobalVariable Name="Image$$ER_RAM_RW$$ZI$$Length"            Value="SIZEOF(.bss)"/>
    <GlobalVariable Name="_use_no_semihosting_swi"                 Value="0"/>

    <GlobalVariable Name="Image$$VECTORS$$Base"     Value="0x18004000"/>
    <GlobalVariable Name="Image$$RO_DATA$$Base"     Value="0x18004000"/>
    <GlobalVariable Name="Image$$RW_DATA$$Base"     Value="0x20600000"/>
    <GlobalVariable Name="Image$$ZI_DATA$$Base"     Value="0x20100000"/>
    <GlobalVariable Name="Image$$TTB$$ZI$$Base"     Value="ADDR(ER_TTB)"/>

    <GlobalVariable Name="Image$$VECTORS$$Limit"    Value="0x18004FFF"/>
    <GlobalVariable Name="Image$$RO_DATA$$Limit"    Value="0x181FFFFF"/>
    <GlobalVariable Name="Image$$RW_DATA$$Limit"    Value="0x206FFFFF"/>
    <GlobalVariable Name="Image$$ZI_DATA$$Limit"    Value="0x201FFFFF"/>

</ScatterFile>
